[PATCH] tls: wrap SNICallback invocation in try/catch
authorMatteo Collina <hello@matteocollina.com>
Tue, 17 Feb 2026 13:26:17 +0000 (14:26 +0100)
committerJérémy Lal <kapouer@melix.org>
Tue, 24 Mar 2026 21:11:25 +0000 (22:11 +0100)
commite3f748f9e344d1a3f8f140c7ff21f954d4e564ed
tree75dcf531262247018659933680eb8bafb8a08d16
parent02e76a7e8cb4a3156cb31279bcef834bd3eb7a5d
[PATCH] tls: wrap SNICallback invocation in try/catch

Wrap the owner._SNICallback() invocation in loadSNI() with try/catch
to route exceptions through owner.destroy() instead of letting them
become uncaught exceptions. This completes the fix from CVE-2026-21637
which added try/catch protection to callALPNCallback,
onPskServerCallback, and onPskClientCallback but missed loadSNI().

Without this fix, a remote unauthenticated attacker can crash any
Node.js TLS server whose SNICallback may throw on unexpected input
by sending a single TLS ClientHello with a crafted server_name value.

Fixes: https://hackerone.com/reports/3556769
Refs: https://hackerone.com/reports/3473882
CVE-ID: CVE-2026-21637
PR-URL: https://github.com/nodejs-private/node-private/pull/839
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
CVE-ID: CVE-2026-21637

Gbp-Pq: Topic sec
Gbp-Pq: Name 56-tls-wrap-SNICallback-invocation-in-try-catch.patch
lib/_tls_wrap.js
test/parallel/test-tls-psk-alpn-callback-exception-handling.js